package com.eascs.ticket.project.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.ticket.common.dao.BaseDao;
import com.eascs.ticket.configuration.entity.TicketTypeConstant;

@Repository
public class ProjectTicketTypeDao extends BaseDao {

	public List<Object[]> getTicketTypeDataSouceByProjectId(String projectId) {
		return this.findObjectsList("select code,name from  ticket_type  where  code in (select ticket_type_code from project_ticket_type where project_id=?) order by order_code", projectId);
	}

	public List<Object[]> getMainTicketTypeDataSouceByProjectId(String projectId) {
		return this.findObjectsList("select code,name from  ticket_type  where  code in (select ticket_type_code from project_ticket_type where project_id=?)  and type<>? order by order_code", projectId, TicketTypeConstant.TYPE_SUB);
	}

	public List<Object[]> getTicketTypeByProjectId(String projectId) {
		return this.findObjectsList("select id,ticket_type_code from project_ticket_type where project_id=?", projectId);
	}

	public List<Object[]> getNotSelectTicketTypeByProjectId(String projectId) {
		return this.findObjectsList("select code,name from ticket_type where  code not in  (select ticket_type_code from project_ticket_type where project_id=?) order by order_code", projectId);
	}

	public int countProjectTicketType(String projectId, String ticketTypeCode) {
		return this.findInteger("select count(1) from ticket where project_id=? and ticket_type_code=?", projectId, ticketTypeCode);
	}

}
